home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7493 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: gryphon.phoenix.net!usenet
  2. From: brucew@phoenix.net (Bruce Wedding)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: pointers
  5. Date: Tue, 27 Feb 1996 00:20:43 GMT
  6. Organization: BranPaul Systems
  7. Message-ID: <4gtir6$d68@gryphon.phoenix.net>
  8. References: <4gqh8g$bo4@news.bu.edu>
  9. NNTP-Posting-Host: dial141.phoenix.net
  10. X-Newsreader: Moe's Newsreader    
  11.  
  12. In comp.lang.c
  13. lachesis@cs.bu.edu (wai yip) wrote:
  14.  
  15. >can someone who knows a lot about pointers help me with this
  16.  
  17. >int i=3,*p;
  18. >
  19. >with the above declaration, what would the bottom lines do?
  20. >*p=&i;
  21. This stores the adress of i at wherever p points.  Not good.
  22.  
  23. >p=i;
  24. This points p at the address 3.  Not good.
  25.  
  26. >*p=i;
  27. This stores 3 at whatever address p is pointing.  May be good or
  28. bad.  Depends if p points at valid memory.  I prefer to
  29. explicitly initialize p.
  30.  
  31. >p=&i;
  32.  
  33. Assigns the address of i to p.  This is the only correct
  34. statement here, in this context.
  35.  
  36.  
  37. Bruce D. Wedding                        Have Compiler, Will Travel!
  38.               Perspicacious Programming Performed Promptly
  39. Katy, Texas, USA, Planet Earth, Milkyway Galaxy, Known Universe
  40.  
  41.